package com.zzptc.myappk1218

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST

class MainActivity : AppCompatActivity() {

    interface SearchService{
        @FormUrlEncoded
        @POST("Interface/UserLine/search")
        fun getAllsearch(@Field("pos")i:Int):Call<SearchData>   //search=getAllsearch


    }




    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
       // JavaClassNew.f3()
       // SearchData("r",7, listOf())
        val retrofit = Retrofit.Builder()
            .baseUrl("http://hh1.me:5001/")
            .addConverterFactory(GsonConverterFactory.create())
            .build()
      val  searchService= retrofit.create(SearchService::class.java)
      var  call=searchService.getAllsearch(1)
      call.enqueue(object :Callback<SearchData> {
          override fun onFailure(call: Call<SearchData>, t: Throwable) {

          }

          override fun onResponse(call: Call<SearchData>, response: Response<SearchData>) {
              tv_text.text=response.body()?.message


          }
      })

    }

      //  var str:String?=null;
        //str?.length;
     fun f1(){

    }

}
